package com.atguigu.tms.mock.config;


import com.atguigu.mock.util.ParamUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Configuration
public class AppConfig {


    //public static Date date=new Date();
    public static Long user_session_count = 1000L;

    public static String reset_all_dim="1";

    public static String mock_clear_user = "0";

    public static String mock_clear_busi = "0";



    public static Integer mock_new_user = 0;

    public static Integer mock_order_count = 1;

    public static Integer mock_user_update_rate=15;

    public static String mock_date_str = "";

    public static Date mock_date = new Date();

    //班次间隔小时
    public static Integer shift_interval_hour=4;

   // public static String[] shift_clock={"13","18"};
    public static Integer[] shift_clock={8, 13 , 18,23 };

    public static Long order_dur_hour_per100m =8L;

    //
    public static Integer line_new_2_driver_km=300;

    public static String default_plan_strategy="1";


    public static Integer[] collect_dur_minute_minmax={15,30};

    public static String mock_type = "log";

    public static String mock_url = "http://localhost:80";



    public static String[] collect_hours= {"10","15"};
    public static String[] commit_hours= {"12","17"};





    public static Integer  collect_estimate_handle_hour=4 ;
    public static Integer  commit_estimate_handle_hour=4 ;



    public static Integer  send_estimate_handle_hour=6 ;




    public static Integer error_rate = 3;

    public static Integer  complex_num=100;

    public static Integer if_realtime = 0;

    public static String if_reset_organ="1";

    public static String  if_reset_line_base="1";

    public static String if_reset_truck="1";

    public static Integer cur_hour_clock=null;

    public static Integer[] start_time_weight;

    public static Integer[] payment_type_weight={10,30,60};

    public static String clear_courier_send;

    public static Integer new_courier_send;


    public static String   clear_courier_collect;

    public static String  reset_courier_collect;
    public static String  reset_courier_delivery;

    public static String   if_reset_sorter="1";




    //public static String address_city;



    public static String kafka_server;
    public static String kafka_topic;





    @Value("${mock.order.count}")
    public void setOrderCount(String orderCount){
        AppConfig.mock_order_count=ParamUtil.checkCount(orderCount);
    }

//    @Value("${mock.address.city}")
//    public void setAddressCity(String address_city){
//        AppConfig.address_city=address_city;
//    }

//    @Value("${mock.organ.reset}")
//    public void setIfResetOrgan(String if_reset_organ){
//        AppConfig.if_reset_organ=if_reset_organ;
//    }

    @Value("${mock.address.complex.num}")
    public void setComplexNum(String complexNum){
        AppConfig.complex_num=  ParamUtil.checkCount(complexNum);
    }




//    @Value("${mock.start-time-weight}")
//    public void setStartTimeWeight(String start_time_weight) {
//        AppConfig.start_time_weight =  ParamUtil.checkRate(start_time_weight) ;
//    }

//    @Value("${mock.payment-type-weight}")
//    public void setPaymentTypeWeight(String payment_type_weight) {
//        AppConfig.payment_type_weight =  ParamUtil.checkRate(payment_type_weight) ;
//    }


    @Value("${mock.new.user}")
    public void setNewUser(String newUser) {
        AppConfig.mock_new_user = ParamUtil.checkCount(newUser);
    }

//    @Value("${mock.if-realtime}")
//    public void setIfRealtime(Integer ifRealtime) {
//        AppConfig.if_realtime = ifRealtime;
//    }






//    @Value("${mock.clear.user}")
//    public void setMockClearUser(String mockClearUser) {
//        AppConfig.mock_clear_user = mockClearUser;
//    }

    @Value("${mock.clear.busi}")
    public void setMockClearBusi(String mockClearBusi) {
        AppConfig.mock_clear_busi = mockClearBusi;
    }



    //

//
//    @Value("${mock.type}")
//    public   void setMock_type(String mock_type) {
//        AppConfig.mock_type = mock_type;
//    }
//
//    @Value("${mock.url}")
//    public   void setMock_url(String mock_url) {
//        AppConfig.mock_url = mock_url;
//    }

//    @Value("${mock.kafka-server}")
//    public   void setKafka_server(String kafka_server) {
//        AppConfig.kafka_server = kafka_server;
//    }
//    @Value("${mock.kafka-topic}")
//    public   void setKafka_topic(String kafka_topic) {
//        AppConfig.kafka_topic = kafka_topic;
//    }







    @Value("${mock.date}")
    public void setMockDate(String mockDate) {

        AppConfig.mock_date_str = mockDate;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            AppConfig.mock_date = simpleDateFormat.parse(mockDate);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException("日期格式不对！");
        }

    }
//
//    @Value("${mock.detail.source-type-rate}")
//    public     void setSourceType(String  sourceTypeRate) {
//        Integer[] sourceTypeRateArray = ParamUtil.checkRate( sourceTypeRate,4);
//        AppConfig.sourceTypeRate = sourceTypeRateArray;
//
//    }
//

//
//
    @Value("${mock.reset-all-dim}")
    public void setIf_get_coupon(String  reset_all_dim ){
        AppConfig.reset_all_dim=  reset_all_dim ;
    }
//
//    @Value("${mock.max.coupon-id}")
//    public   void setMaxCouponId(String couponId) {
//        AppConfig.max_coupon_id = ParamUtil.checkCount(couponId);
//    }
//


}
